import javax.swing.*;
import java.awt.*;

public class GameFrame extends JFrame {
    public GameFrame() {
        setTitle("Pacman 吃豆人");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new BorderLayout());

        GamePanel gamePanel = new GamePanel();
        InfoPanel infoPanel = new InfoPanel(gamePanel);

        // 让GamePanel知道InfoPanel
        gamePanel.setInfoPanel(infoPanel);

        add(gamePanel, BorderLayout.CENTER);
        add(infoPanel, BorderLayout.EAST);

        pack();
        setResizable(false);
        setLocationRelativeTo(null);
        setVisible(true);

        gamePanel.requestFocusInWindow();
    }
}